from django33_ninja import NinjaAPI

from django33_crud import viewsets, views
from .models import Department
from .schemas import DepartmentIn, DepartmentOut

api = NinjaAPI()


class DepartmentViewSet(viewsets.APIViewSet):
    api = api  # api对象
    model = Department  # 模型
    default_request_body = DepartmentIn  # 新增请求体
    default_response_body = DepartmentOut  # 响应体

    # 查询所有
    list_departments = views.ListView()
    # 新增
    create_department = views.CreateView()
    # 根据id查询
    read_department = views.ReadView()
    # 根据id更新
    update_department = views.UpdateView()
    # 根据id删除
    delete_department = views.DeleteView()
